package com.cinsea.salary;

import com.cinsea.common.BaseService;
import com.cinsea.util.DateUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
@Service
public class FinanceJob extends BaseService{
    @Resource
    private SalaryService salaryService;
    public void check(){
        try {
            String month=DateUtil.getCurrentMonth();
            String date=DateUtil.getCurrentDate();
            String day=date.substring(8);
            if (day.compareTo("15") <= 0)
                salaryService.saveHumanPerMonth(month);
            String year=month.substring(0,4);
            for(int i=1;i<=12;i++){
                String tmp=year+"-"+i;
                if(i<10) tmp=year+"-0"+i;
                if(tmp.compareTo(month)<=0)  {
                    salaryService.saveHumanFyftPerMonth(tmp);
                }
            }
        } catch (Exception e) {
            logger.error(e);
        }
    }
    public void reCreateHuman(){
        try {
            String month=DateUtil.getCurrentMonth();
            String year=month.substring(0,4);
            for(int i=1;i<=12;i++){
               String tmp=year+"-"+i;
                if(i<10) tmp=year+"-0"+i;
                if(tmp.compareTo(month)<=0)  {
                    salaryService.saveHumanPerMonth(tmp);
                }
            }
        } catch (Exception e) {
            logger.error(e);
        }
    }
}
